﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace KATS_Client.UI
{
    /// <summary>
    /// The location text box
    /// </summary>
    class ToolStripLocationTextBox :ToolStripTextBox 
    {
        /// <summary>
        /// Fires whenever the enter key is pressed
        /// </summary>
        public event EventHandler<EventArgs> EnterKeyPressed;

        /// <summary>
        /// Fires whenever the esc key is pressed
        /// </summary>
        public event EventHandler<EventArgs> EscKeyPressed;

        /// <summary>
        /// Process the keys
        /// </summary>
        /// <param name="m"></param>
        /// <param name="keyData"></param>
        /// <returns></returns>
        protected override bool ProcessCmdKey(ref Message m, Keys keyData)
        {
            if (keyData == Keys.Enter || keyData == Keys.Return)
            {
                if (EnterKeyPressed != null)
                    EnterKeyPressed(this, new EventArgs());
                return true;
            }
            else if (keyData == Keys.Escape)
            {
                if (EscKeyPressed != null)
                    EscKeyPressed(this, new EventArgs());
                return true;
            }
            return base.ProcessCmdKey(ref m, keyData);
        }

    }
}
